<!--
Author: Quan Van Sinh
Email : sinhvnb@vietnambiz.com
Mobile: 0972405165
-->
<?php include ADMIN_INCLUDE_DIR."/header.php";?>
<script language="javascript" type="text/javascript">
    var popupImageParams = '&forModule=news&position=content';
    /*
    ['Source','-','Save','NewPage','Preview','-','Templates'],
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Link','Unlink','Anchor'],
    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
    '/',
    ['Styles','Format','Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks','-','About']
     */
    $(document).ready(function (){
        CKEDITOR.config.resize_enabled = false;
        CKEDITOR.config.width = 500;
        CKEDITOR.config.height = 400;
        CKEDITOR.replace( 'content',
        {
            toolbar :
                [['Maximize', '-','Format','Font','FontSize','-','TextColor','BGColor','-','Bold','Italic','Underline','Strike','-','NumberedList','BulletedList','-','Outdent','Indent','Blockquote','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock', '-','Image','Table','-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ]]
        });

    });

    function genTags(){
        if($("#title").val()==''){
            alert('Title can not be blank!');
            $("#title").focus();
            return false;
        }
        if($("#description").val()==''){
            alert('Description can not be blank!');
            $("#description").focus();
            return false;
        }
        var content = CKEDITOR.instances.content.getData();
        if(content==''){
            alert('Content can not be blank!');
            CKEDITOR.instances.content.focus();
            return false;
        }
        $.ajax({
            url: ADMIN_URL+'/index.php?module=news&action=gen-tags',
            type: 'POST',
            data: "title=" + $("#title").val() + "&description=" + $("#description").val() + "&content=" + content + "&frequency=" + $("#frequency1").val()+','+$("#frequency2").val()+','+$("#frequency3").val()+','+$("#frequency4").val()+','+$("#frequency5").val()+','+$("#frequency6").val(),
            error: function(){
                alert('Error loading tags infomation!');
            },
            success: function(data){
                $("#keywordAlert").html('<span style="color:green;">Generate tags successful!</span>');
                $("#keywordAlert").show();
                $("#tagResult").html(data);
            }
        });
    }
    function clearTags(){
        $("input[name=keyword[]]").val('');
    }

    function keyword_remove(no){
        if($("#removedTags").val()==''){
            $("#removedTags").val($("#removedTags").val() + $("#key"+no).val())
        }else{
            $("#removedTags").val($("#removedTags").val() + ',' + $("#key"+no).val());
        }
        $('#k'+no).html('');
        $('#k'+no).hide()
        $("#keywordAlert").hide();
        $("#keywordAlert").html('<span style="color:green;">Remove keyword successful!</span>');
        $("#keywordAlert").show();
    }

    function keyword_spam(no){
        if(no!=''){
            if($("#removedTags").val()==''){
                $("#removedTags").val($("#removedTags").val() + $("#key"+no).val())
            }else{
                $("#removedTags").val($("#removedTags").val() + ',' + $("#key"+no).val());
            }
            $.ajax({
                url: ADMIN_URL+'/index.php?module=news&action=gen-tags',
                type: 'GET',
                data: "keyword=" + $("#key"+no).val(),
                error: function(){
                    alert('Error add spam!');
                },
                success: function(){
                    $("#keywordAlert").hide('slow');
                    $('#k'+no).html('');
                    $('#k'+no).hide()
                    $("#keywordAlert").html('<span style="color:green;">Add to spam successful!</span>');
                    $("#keywordAlert").show('slow');
                }
            });
        }
    }
    function submitFormAddNews(submitType){
        if(submitType=='exit'){
            $("#submitType").val('exit');
            $("#submitFrmNewsAdd").click();
        }
    }
</script>
<div class="container_l">
    <form name="formNewsAddCategory" method="POST" action="">
        <div class="title_user"><img src="images/icon1.gif" />Tin tức</div>
        <div class="table_user">
            <div class="table_user_in2">
                <?php
                show_error();
                show_success();
                ?>
                <fieldset>
                    <legend accesskey="N">Thêm mới Tin tức</legend>
                    <div class="lineaddnew">
                        <div style="width:70%;float:left;">
                            <div class="lineform">
                                <div class="divlabel_news">Tiêu đề: <font color="#FF0000">*</font></div>
                                <div class="divform"><input type="text" id="title" name="title" value="<?php echo htmlentities($_REQUEST['title'], ENT_QUOTES, 'UTF-8');?>" style="width:99%;"/></div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Danh mục: <font color="#FF0000">*</font></div>
                                <div class="divform">
                                    <select name="cat_id" style="width:99%;">
                                        <?php
                                        $arrNewsCat = listAllNewsCategory($parent_id = 0);
                                        for($i=0;$i<count($arrNewsCat);$i++) {
                                            ?>
                                        <option <?php echo setSelectedBoxValue($_REQUEST['cat_id'], $arrNewsCat[$i]['cat_id']);?> value="<?php echo $arrNewsCat[$i]['cat_id'];?>"><?php echo $arrNewsCat[$i]['cat_title'];?></option>
                                        <?php
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Mô tả ngắn: <font color="#FF0000">*</font></div>
                                <div class="divform"><textarea id="description" name="description" cols="10" rows="10" style="overflow:hidden;width:99%;"><?php echo $_REQUEST['description'];?></textarea></div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Hình ảnh:</div>
                                <div class="divform">
                                    <input type="hidden" id="image" name="image" value="<?php echo $_REQUEST['image'];?>"/>
                                    <img id="imgDisplay" src="<?php if($_REQUEST['image']!='') {echo $_REQUEST['image'];}else {echo 'images/no_image.jpg';}?>" style="float:left; width:120px;" alt=""/>&nbsp;&nbsp;
                                    <input type="button" value="Select image" onclick="popupImages('&forModule=news');" class="button" style="float:left;width:120px;margin-left:20px;margin-top:46px;" />
                                </div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Thể loại:</div>
                                <div style="margin-top:6px;">&nbsp;&nbsp;&nbsp;<input type="radio" name="type" value="hot" <?php echo setCheckedBoxValue($_REQUEST['active'],'hot');?> /> Hot news &nbsp;&nbsp; <input type="radio" name="type" value="normal" <?php echo setCheckedBoxValue($_REQUEST['type'],'normal',true);?> /> Normal news</div>
                            </div>

                            <div class="lineform">
                                <div class="divlabel_news">Mội dung: <font color="#FF0000">*</font></div>
                                <div style="margin-left:16%;">
                                    <textarea name="content" id="content" cols="2" rows="10"></textarea>
                                </div>
                            </div>
                        </div>
                   
                    </div>
                    <div class="spacer1"><span></span></div>
                </fieldset>
                <div class="linesubmit">
                    <input type="hidden" name="submitType" id="submitType" value="">
                    <input type="submit" name="submitFrmNewsAdd" id="submitFrmNewsAdd" value="Lưu lại" class="button" />
                    <input type="button" name="submitFrmNewsAddAndExit" onclick="document.location='?module=news';" value="Thoát" class="button" />
                </div>
            </div>
        </div>
    </form>
</div>
<?php
include "inc/right.php";
include ADMIN_INCLUDE_DIR."/footer.php";
?>